﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="UserManage.aspx.cs" Inherits="NetDon.OA.Portal.Admin.UserManage" %>

<%@ Register Src="../Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<%@ Register Src="../Components/Organization.ascx" TagName="OrganizationTree" TagPrefix="uc1" %>
<%@ Import Namespace="NetDon.OA.Business" %>
<%@ Import Namespace="NetDon.OA.Interface" %>
<%@ Import Namespace="NetDon.OA.Interface.Configuration" %>
<%@ Import Namespace="NetDon.OA.Portal" %>
<%@ Import Namespace="NetDon.Utilities" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var userDialogSize = { width: 620, height: 500 };

        function modifyOreditUser(userId, companyId, DepartId) {
            $dialog('<%=ResolveUrl(SiteUrls.Admin.UserCreate) %>?UserId=' + userId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            })
        }
        function createOreditUser() {
            $dialog('<%=ResolveUrl(SiteUrls.Admin.UserCreate) %>', userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            })
        }
        function deleteUser(userId) {
            $confirm('确认删除此用户吗？', function (result) {
                if (result) {
                    $text($get('<%=fieldUserId.ClientID %>'), userId);
                    $get('<%=btnDeleteUser.ClientID %>').click();
                }
            })
        }

        function viewUser(sender, args) {
            var userId = $attr(sender.get_selectedRow(), 'UserId');
            $dialog('<%= ResolveUrl(SiteUrls.Admin.UserDetail) %>?UserId=' + userId, userDialogSize);
        }
        function viewUserEx(userId) {
            $dialog('<%= ResolveUrl(SiteUrls.Admin.UserDetail) %>?UserId=' + userId, userDialogSize);
        }
        function activateUser(userId) {
            $confirm('确认激活此用户吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldUserId.ClientID %>'), userId);
                    $get('<%=btnActivation.ClientID %>').click();
                }
            })
        }
        function unActivateUser(userId) {
            $confirm('确认不激活此用户吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldUserId.ClientID %>'), userId);
                    $get('<%=btnUnActivation.ClientID %>').click();
                }
            })
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top" style="width: 260px;">
                        <uc1:OrganizationTree runat="server" Width="260px" ID="treeOrganization" />
                    </td>
                    <td valign="top">
                        <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearch">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <NetDon:FormPanel ID="FormPanel1" runat="server" RepeatColumns="2">
                                            <Items>
                                                <NetDon:FormItem HeaderText="用户名">
                                                    <ContentTemplate>
                                                        <asp:TextBox ID="txtLoginName" runat="server"></asp:TextBox>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="邮箱">
                                                    <ContentTemplate>
                                                        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="姓名">
                                                    <ContentTemplate>
                                                        <asp:TextBox ID="txtFullName" runat="server"></asp:TextBox>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="用户类型">
                                                    <ContentTemplate>
                                                        <asp:DropDownList ID="dplUserType" runat="server" DataSourceID="EnumDataSourceUserType"
                                                            DataTextField="Description" DataValueField="Name">
                                                        </asp:DropDownList>
                                                        <NetDon:EnumDataSource ID="EnumDataSourceUserType" runat="server" EmptyItemType="All"
                                                            TypeName="NetDon.OA.Interface.UserType">
                                                        </NetDon:EnumDataSource>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="岗位">
                                                    <ContentTemplate>
                                                        <NetDon:PositionDropDown runat="server" ID="ddlPosition">
                                                        </NetDon:PositionDropDown>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="状态" ColumnSpan="2">
                                                    <ContentTemplate>
                                                        <asp:DropDownList ID="dplUserStatus" runat="server" DataSourceID="EnumDataSourceUserStatus"
                                                            DataTextField="Description" DataValueField="Name">
                                                        </asp:DropDownList>
                                                        <NetDon:EnumDataSource ID="EnumDataSourceUserStatus" runat="server" EmptyItemType="All"
                                                            TypeName="NetDon.OA.Interface.UserStatus">
                                                        </NetDon:EnumDataSource>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                            </Items>
                                        </NetDon:FormPanel>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align:right " >
                                        <asp:Button ID="btnSearch" runat="server" Text="查询" SkinID="Button80" OnClick="btnSearch_Click" />
                                        <asp:Button ID="btnCreateNew" runat="server" Text="创建"></asp:Button>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                        <div style="margin-top: 10px">
                            <NetDon:GridView ID="gridUsers" runat="server" DataKeyNames="UserId" AllowSorting="true"
                                OnRowDataBound="gridUsers_RowDataBound">
                                <Columns>
                                    <NetDon:BoundField HeaderText="用户名" SortExpression="UserName" DataField="UserName">
                                    </NetDon:BoundField>
                                    <NetDon:TemplateField HeaderText="姓名" SortExpression="FullName">
                                        <ItemTemplate>
                                            <%#Server.HtmlEncode(Convert.ToString(Eval("FullName")))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="别名" SortExpression="NickName">
                                        <ItemTemplate>
                                            <%#Server.HtmlEncode(Convert.ToString(Eval("NickName")))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="性别" SortExpression="Gender">
                                        <ItemTemplate>
                                            <%#Server.HtmlEncode(EnumUtilities.GetDescription((GenderType)Convert.ToInt32(Eval("Gender") == DBNull.Value ? GenderType.UnKnown : Eval("Gender"))))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:BoundField HeaderText="Email" SortExpression="Email" DataField="Email">
                                    </NetDon:BoundField>
                                    <NetDon:TemplateField HeaderText="用户类型" SortExpression="Type">
                                        <ItemTemplate>
                                            <%#Server.HtmlEncode(EnumUtilities.GetDescription((UserType)Convert.ToInt32(Eval("Type"))))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="岗位" SortExpression="PostName">
                                        <ItemTemplate>
                                            <%#Eval("PostName") %>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="创建时间" SortExpression="CreateDate">
                                        <ItemTemplate>
                                            <%#( Eval("CreateDate")==DBNull.Value? "":(Convert.ToDateTime(Eval("CreateDate"))).ToString(SystemConfiguration.DateFormat))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="状态" SortExpression="UserStatus">
                                        <ItemTemplate>
                                            <%#Server.HtmlEncode(EnumUtilities.GetDescription((UserStatus)Convert.ToInt32(Eval("UserStatus"))))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="80px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnActivate" Style="margin-left: 5px" ToolTip="Activate" runat="server"
                                                SkinID="Activate" ImageAlign="AbsMiddle" CausesValidation="false" Visible='<%# !Convert.ToBoolean(Eval("UserStatus")) %>' />
                                            <asp:ImageButton ID="btnUnActivate" Style="margin-left: 5px" ToolTip="No Activate"
                                                runat="server" SkinID="UnActivate" ImageAlign="AbsMiddle" CausesValidation="false"
                                                Visible='<%# Convert.ToBoolean(Eval("UserStatus")) %>' />
                                            <asp:ImageButton ID="btnEdit" Style="margin-left: 5px" ToolTip="Edit" runat="server"
                                                SkinID="Modify" ImageAlign="AbsMiddle" CausesValidation="false" />
                                            <asp:ImageButton ID="btnDelete" ToolTip="Delete" runat="server" SkinID="Delete" ImageAlign="AbsMiddle"
                                                CausesValidation="false" CommandName="DeleteUser" CommandArgument='<%# Eval("UserId") %>' />
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                </Columns>
                            </NetDon:GridView>
                            <uc1:GridPager ID="PagerUsers" runat="server" TargetControlID="gridUsers" PageSize="20"
                                OnPerformGetCondition="PagerUsers_PerformGetCondition" OnPerformGetRecordCount="PagerUsers_PerformGetRecordCount"
                                OnPerformGetPageData="PagerUsers_PerformGetPageData" />
                        </div>
                        <div style="margin-top: 10px; text-align: center">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
                                ShowMessageBox="True" ShowSummary="False" />
                            <asp:Button ID="btnModify" runat="server" OnClick="btnModify_Click" Style="display: none"
                                CausesValidation="False" />
                            <asp:Button ID="btnReload" runat="server" OnClick="btnReload_Click" Style="display: none"
                                CausesValidation="False" />
                            <asp:HiddenField ID="fieldUserId" runat="server" />
                            <asp:Button ID="btnActivation" runat="server" OnClick="btnActivation_Click" Style="display: none"
                                CausesValidation="False" />
                            <asp:Button ID="btnUnActivation" runat="server" OnClick="btnUnActivation_Click" Style="display: none"
                                CausesValidation="False" />
                            <asp:Button ID="btnDeleteUser" runat="server" OnClick="btnDeleteUser_Click" Style="display: none"
                                CausesValidation="False" />
                        </div>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
